package com.baicaoyuan.web.repository;

import com.baicaoyuan.web.model.LotteryUserDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

public interface LotteryUserRepository extends JpaRepository<LotteryUserDO, Long> {
    List<LotteryUserDO> findByUserId(Long userId);

    @Query(value = "SELECT lu.*, u.telephone, u.province, u.city, u.area, u.address from t_lottery_user  lu LEFT JOIN t_user u on lu.user_id_fk = u.id where u.telephone like ?1 and lu.status = ?4 order by lu.create_time DESC LIMIT ?2, ?3 ", nativeQuery = true)
    List<Object[]> getPage(String telephone, Integer page, Integer size, Integer status);

    @Query(value = "SELECT count(*) from t_lottery_user  lu LEFT JOIN t_user u on lu.user_id_fk = u.id where u.telephone like ?1  and lu.status =?2 ", nativeQuery = true)
    Integer count(String telephone,Integer status);
}